<?php
ini_set('display_errors', 1);
error_reporting(-1);
require_once '/data/wwwroot/g_vendor/autoload.php';
ini_set('memory_limit', '1024M');


$productJsonStr = <<<JSON
 [
    {
      "id": 1,
      "remark": null,
      "type": "服务",
      "product_id": null,
      "name": "装修基金",
      "value": "5000",
      "count": null,
      "w_bg_pic": null,
      "service_link": "https://lego.haohaozhu.cn/lego/151.html"
    },
    {
      "id": 2,
      "remark": null,
      "type": "商品",
      "product_id": "218867",
      "name": "井井化妆品收纳箱",
      "value": "499",
      "count": "10",
      "w_bg_pic": "https://img.haohaozhu.cn/Op-imageShow/d8fbb20di0di0Kp00r8ifml?iv=1",
      "service_link": null
    },
    {
      "id": 3,
      "remark": null,
      "type": "商品",
      "product_id": "123742",
      "name": "优瑞家洗地机",
      "value": "5390",
      "count": "1",
      "w_bg_pic": "https://img.haohaozhu.cn/Op-imageShow/d6bc420di0di0x800r8iocg?iv=1",
      "service_link": null
    },
    {
      "id": 4,
      "remark": null,
      "type": "商品",
      "product_id": "182325",
      "name": "霍格玫瑰花贵妇装饰画",
      "value": "288",
      "count": "20",
      "w_bg_pic": "https://img.haohaozhu.cn/Op-imageShow/c5aa220di0di0LI00r8ippo?iv=1",
      "service_link": null
    },
    {
      "id": 5,
      "remark": null,
      "type": "商品",
      "product_id": "27522",
      "name": "根元菌智能鞋柜",
      "value": "3980",
      "count": "2",
      "w_bg_pic": "https://img.haohaozhu.cn/Op-imageShow/af6f320di0di0da00r8isq5?iv=1",
      "service_link": null
    },
    {
      "id": 6,
      "remark": null,
      "type": "商品",
      "product_id": "186541",
      "name": "森朴欧式建筑书房挂画",
      "value": "222",
      "count": "22",
      "w_bg_pic": "https://img.haohaozhu.cn/Op-imageShow/a50d920di0di0xE00r8iv31?iv=1",
      "service_link": null
    },
    {
      "id": 7,
      "remark": null,
      "type": "商品",
      "product_id": "218754",
      "name": "猫王Mate·3音箱",
      "value": "2499",
      "count": "3",
      "w_bg_pic": "https://img.haohaozhu.cn/Op-imageShow/ef30a20di0di0cL00r8kfld?iv=1",
      "service_link": null
    },
    {
      "id": 8,
      "remark": null,
      "type": "商品",
      "product_id": "142744",
      "name": "致家家居多立克圆桌",
      "value": "4880",
      "count": "1",
      "w_bg_pic": "https://img.haohaozhu.cn/Op-imageShow/8df7920di0di0N100r8k8ps?iv=1",
      "service_link": null
    },
    {
      "id": 9,
      "remark": null,
      "type": "商品",
      "product_id": "220154",
      "name": "稚蓝灯饰觅手提灯",
      "value": "690",
      "count": "8",
      "w_bg_pic": "https://img.haohaozhu.cn/Op-imageShow/ce05e30di0di0v800r8k8ms?iv=1",
      "service_link": null
    },
    {
      "id": 10,
      "remark": null,
      "type": "商品",
      "product_id": "159298",
      "name": "IQAir空气净化器",
      "value": "14980",
      "count": "1",
      "w_bg_pic": "https://img.haohaozhu.cn/Op-imageShow/e1bdf20di0di0FL00r8khex?iv=1",
      "service_link": null
    },
    {
      "id": 11,
      "remark": null,
      "type": "商品",
      "product_id": "214680",
      "name": "舒纳沃恩盖世全能漆",
      "value": "498",
      "count": "10",
      "w_bg_pic": "https://img.haohaozhu.cn/Op-imageShow/4320930di0di07b00r8kk2a?iv=1",
      "service_link": null
    },
    {
      "id": 12,
      "remark": null,
      "type": "商品",
      "product_id": "218529",
      "name": "吉博力滨娜智能挂厕",
      "value": "11999",
      "count": "1",
      "w_bg_pic": "https://img.haohaozhu.cn/Op-imageShow/cfdea30di0di0ip00r8kk3h?iv=1",
      "service_link": null
    },
    {
      "id": 13,
      "remark": null,
      "type": "商品",
      "product_id": "212951",
      "name": "FLEXA儿童帐篷",
      "value": "1489",
      "count": "4",
      "w_bg_pic": "https://img.haohaozhu.cn/Op-imageShow/3cdd1309u09u0Xo00r8kna1?iv=1",
      "service_link": null
    },
    {
      "id": 14,
      "remark": null,
      "type": "商品",
      "product_id": "218363",
      "name": "TAMEH方形置物架",
      "value": "840",
      "count": "6",
      "w_bg_pic": "https://img.haohaozhu.cn/Op-imageShow/4b6b430di0di0qF00r8kncp?iv=1",
      "service_link": null
    },
    {
      "id": 15,
      "remark": null,
      "type": "商品",
      "product_id": "57963",
      "name": "番茄设计出品米白床 ",
      "value": "7723",
      "count": "1",
      "w_bg_pic": "https://img.haohaozhu.cn/Op-imageShow/94a1430di0di0d800r8ko4f?iv=1",
      "service_link": null
    },
    {
      "id": 16,
      "remark": null,
      "type": "商品",
      "product_id": "70344",
      "name": "浮生记墨尔本餐边柜",
      "value": "3360",
      "count": "2",
      "w_bg_pic": "https://img.haohaozhu.cn/Op-imageShow/94a1430di0di0d800r8ko4f?iv=1",
      "service_link": null
    },
    {
      "id": 17,
      "remark": null,
      "type": "商品",
      "product_id": "184834",
      "name": "恺丽之家真皮沙发",
      "value": "8570",
      "count": "1",
      "w_bg_pic": "https://img.haohaozhu.cn/Op-imageShow/bcc6530di0di0BZ00r8kojw?iv=1",
      "service_link": null
    },
    {
      "id": 18,
      "remark": null,
      "type": "商品",
      "product_id": "216925",
      "name": "米诺家居夏木床头柜",
      "value": "1012",
      "count": "5",
      "w_bg_pic": "https://img.haohaozhu.cn/Op-imageShow/8fcc430di0di0Wx00r8konf?iv=1",
      "service_link": null
    },
    {
      "id": 19,
      "remark": null,
      "type": "商品",
      "product_id": "197614",
      "name": "木邻哈尔展示柜",
      "value": "1050",
      "count": "5",
      "w_bg_pic": "https://img.haohaozhu.cn/Op-imageShow/d710a20m80m80cy00r8kp8j?iv=1",
      "service_link": null
    },
    {
      "id": 20,
      "remark": null,
      "type": "商品",
      "product_id": "217174",
      "name": "寝物RTAER日暮床",
      "value": "5288",
      "count": "1",
      "w_bg_pic": "https://img.haohaozhu.cn/Op-imageShow/1004b30di0di0hF00r8kpi1?iv=1",
      "service_link": null
    },
    {
      "id": 21,
      "remark": null,
      "type": "商品",
      "product_id": "62431",
      "name": "十八纸风琴折叠微纸凳",
      "value": "169",
      "count": "30",
      "w_bg_pic": "https://img.haohaozhu.cn/Op-imageShow/d22e730di0di0Hx00r8kq2x?iv=1",
      "service_link": null
    },
    {
      "id": 22,
      "remark": null,
      "type": "商品",
      "product_id": "150831",
      "name": "西屋S3乳胶弹簧床垫",
      "value": "6999",
      "count": "1",
      "w_bg_pic": "https://img.haohaozhu.cn/Op-imageShow/203fa30di0di0CV00r8kq6l?iv=1",
      "service_link": null
    },
    {
      "id": 23,
      "remark": null,
      "type": "商品",
      "product_id": "205768",
      "name": "优尼居小河马单人沙发",
      "value": "2560",
      "count": "2",
      "w_bg_pic": "https://img.haohaozhu.cn/Op-imageShow/39da130di0di0tG00r8kq9z?iv=1",
      "service_link": null
    },
    {
      "id": 24,
      "remark": null,
      "type": "商品",
      "product_id": "27099",
      "name": "吱音袋走茶几",
      "value": "1499",
      "count": "4",
      "w_bg_pic": "https://img.haohaozhu.cn/Op-imageShow/39cc030di0di0YM00r8kqdp?iv=1",
      "service_link": null
    },
    {
      "id": 25,
      "remark": null,
      "type": "商品",
      "product_id": "136160",
      "name": "SOMEONESOMETIME餐椅",
      "value": "1976",
      "count": "3",
      "w_bg_pic": "https://img.haohaozhu.cn/Op-imageShow/6592130di0di09Q00r8ks0s?iv=1",
      "service_link": null
    },
    {
      "id": 26,
      "remark": null,
      "type": "商品",
      "product_id": "192150",
      "name": "稍安物造移动挂衣架",
      "value": "1687",
      "count": "3",
      "w_bg_pic": "https://img.haohaozhu.cn/Op-imageShow/74dcf30di0di0oV00r8ks5b?iv=1",
      "service_link": null
    },
    {
      "id": 27,
      "remark": null,
      "type": "商品",
      "product_id": "219178",
      "name": "生野安室满月五斗柜",
      "value": "2980",
      "count": "2",
      "w_bg_pic": "https://img.haohaozhu.cn/Op-imageShow/e4db830di0di0TD00r8ksb1?iv=1",
      "service_link": null
    },
    {
      "id": 28,
      "remark": null,
      "type": "商品",
      "product_id": "16122",
      "name": "SUFAN舒梵茶几",
      "value": "1399",
      "count": "4",
      "w_bg_pic": "https://img.haohaozhu.cn/Op-imageShow/4d7f530di0di0hL00r8ksft?iv=1",
      "service_link": null
    },
    {
      "id": 29,
      "remark": null,
      "type": "商品",
      "product_id": "198003",
      "name": "听栖哈珀无扶手椅",
      "value": "1099",
      "count": "5",
      "w_bg_pic": "https://img.haohaozhu.cn/Op-imageShow/8e42230di0di0G000r8kslo?iv=1",
      "service_link": null
    },
    {
      "id": 30,
      "remark": null,
      "type": "商品",
      "product_id": "41510",
      "name": "异果酱月芽床头柜",
      "value": "1380",
      "count": "4",
      "w_bg_pic": "https://img.haohaozhu.cn/Op-imageShow/fa96230di0di0Wz00r8ksnu?iv=1",
      "service_link": null
    },
    {
      "id": 31,
      "remark": null,
      "type": "商品",
      "product_id": "59681",
      "name": "二黑木作白马落地灯",
      "value": "810",
      "count": "7",
      "w_bg_pic": "https://img.haohaozhu.cn/Op-imageShow/2094b30di0di0vT00r8kstk?iv=1",
      "service_link": null
    },
    {
      "id": 32,
      "remark": null,
      "type": "商品",
      "product_id": "100561",
      "name": "蓝盒子记忆棉弹簧床垫",
      "value": "2750",
      "count": "2",
      "w_bg_pic": "https://img.haohaozhu.cn/Op-imageShow/1f26d20di0di0Ba00r8q4ly?iv=1",
      "service_link": null
    },
    {
      "id": 33,
      "remark": null,
      "type": "商品",
      "product_id": "190319",
      "name": "尾巴生活帐篷喵屋",
      "value": "129",
      "count": "40",
      "w_bg_pic": "https://img.haohaozhu.cn/Op-imageShow/9997120di0di0Qu00r8q4um?iv=1",
      "service_link": null
    },
    {
      "id": 34,
      "remark": null,
      "type": "商品",
      "product_id": "151244",
      "name": "云物生活小光置物盘",
      "value": "109",
      "count": "50",
      "w_bg_pic": "https://img.haohaozhu.cn/Op-imageShow/5c40720di0di0OM00r8rs3c?iv=1",
      "service_link": null
    },
    {
      "id": 35,
      "remark": null,
      "type": "商品",
      "product_id": "27244",
      "name": "宏微地球矿岩黑地球仪",
      "value": "1480",
      "count": "3",
      "w_bg_pic": "https://img.haohaozhu.cn/Op-imageShow/28afc20di0di0WJ00r8rrui?iv=1",
      "service_link": null
    },
    {
      "id": 36,
      "remark": null,
      "type": "商品",
      "product_id": "215836",
      "name": "北鼎粉色珐琅锅",
      "value": "1418",
      "count": "4",
      "w_bg_pic": "https://img.haohaozhu.cn/Op-imageShow/262dc20di0di0Eb00r8q6s7?iv=1",
      "service_link": null
    },
    {
      "id": 37,
      "remark": null,
      "type": "商品",
      "product_id": "134859",
      "name": "plumpoem托盘",
      "value": "139.8",
      "count": "36",
      "w_bg_pic": "https://img.haohaozhu.cn/Op-imageShow/1497b20di0di08700r8q77d?iv=1",
      "service_link": null
    },
    {
      "id": 38,
      "remark": null,
      "type": "商品",
      "product_id": "145291",
      "name": "邦先生M33晾衣架",
      "value": "1899",
      "count": "3",
      "w_bg_pic": "https://img.haohaozhu.cn/Op-imageShow/e7c8b20di0di0wu00r8q7mi?iv=1",
      "service_link": null
    },
    {
      "id": 39,
      "remark": null,
      "type": "商品",
      "product_id": "216823",
      "name": "半日闲贝果枕",
      "value": "499",
      "count": "11",
      "w_bg_pic": "https://img.haohaozhu.cn/Op-imageShow/2504a20di0di0Kn00r8q82f?iv=1",
      "service_link": null
    },
    {
      "id": 40,
      "remark": null,
      "type": "商品",
      "product_id": "196468",
      "name": "睿米EVA扫地机器人",
      "value": "5699",
      "count": "1",
      "w_bg_pic": "https://img.haohaozhu.cn/Op-imageShow/bd31720di0di0y100r8q8ab?iv=1",
      "service_link": null
    },
    {
      "id": 41,
      "remark": null,
      "type": "商品",
      "product_id": "220318",
      "name": "izzyand挂画",
      "value": "875",
      "count": "6",
      "w_bg_pic": "https://img.haohaozhu.cn/Op-imageShow/cf45720di0di0tc00r8s3db?iv=1",
      "service_link": null
    },
    {
      "id": 42,
      "remark": null,
      "type": "商品",
      "product_id": "217792",
      "name": "鲁大爷迷你手心摆台",
      "value": "107",
      "count": "50",
      "w_bg_pic": "https://img.haohaozhu.cn/Op-imageShow/d265620m80m80gu00r8q9rn?iv=1",
      "service_link": null
    },
    {
      "id": 43,
      "remark": null,
      "type": "商品",
      "product_id": "190892",
      "name": "苏老伯乳胶床垫",
      "value": "2399",
      "count": "2",
      "w_bg_pic": "https://img.haohaozhu.cn/Op-imageShow/7b23720di0di0yS00r8q901?iv=1",
      "service_link": null
    },
    {
      "id": 44,
      "remark": null,
      "type": "商品",
      "product_id": "29837",
      "name": "林芃家品云宿F款床垫",
      "value": "2879",
      "count": "2",
      "w_bg_pic": "https://img.haohaozhu.cn/Op-imageShow/e5a9720di0di0s600r8qaqb?iv=1",
      "service_link": null
    },
    {
      "id": 45,
      "remark": null,
      "type": "商品",
      "product_id": "220244",
      "name": "纳曲画面镜",
      "value": "100",
      "count": "51",
      "w_bg_pic": "https://img.haohaozhu.cn/Op-imageShow/9af9020di0di0Jf00r8rls1?iv=1",
      "service_link": null
    },
    {
      "id": 46,
      "remark": null,
      "type": "商品",
      "product_id": "162369",
      "name": "正植青年柠檬树",
      "value": "599",
      "count": "10",
      "w_bg_pic": "https://img.haohaozhu.cn/Op-imageShow/66c5b20di0di0ky00r8s4j3?iv=1",
      "service_link": null
    },
    {
      "id": 47,
      "remark": null,
      "type": "商品",
      "product_id": "183453",
      "name": "天方烨毯手工羊毛地毯",
      "value": "1999",
      "count": "3",
      "w_bg_pic": "https://img.haohaozhu.cn/Op-imageShow/28b9020di0di0tZ00r8rmjl?iv=1",
      "service_link": null
    },
    {
      "id": 48,
      "remark": null,
      "type": "商品",
      "product_id": "140379",
      "name": "日立多功能电饭煲",
      "value": "5800",
      "count": "1",
      "w_bg_pic": "https://img.haohaozhu.cn/Op-imageShow/3713d20di0di08D00r8qc1z?iv=1",
      "service_link": null
    },
    {
      "id": 49,
      "remark": null,
      "type": "商品",
      "product_id": "220139",
      "name": "甜梨墙面实木挂件",
      "value": "100",
      "count": "51",
      "w_bg_pic": "https://img.haohaozhu.cn/Op-imageShow/596a720di0di0W600r8rm5p?iv=1",
      "service_link": null
    },
    {
      "id": 50,
      "remark": null,
      "type": "商品",
      "product_id": "173807",
      "name": "Zeroroom床垫",
      "value": "5200",
      "count": "1",
      "w_bg_pic": "https://img.haohaozhu.cn/Op-imageShow/85d5520di0di05a00r8qcfy?iv=1",
      "service_link": null
    },
    {
      "id": 51,
      "remark": null,
      "type": "商品",
      "product_id": "84368",
      "name": "博净D-1分体式集成灶",
      "value": "4980",
      "count": "1",
      "w_bg_pic": "https://img.haohaozhu.cn/Op-imageShow/5221220di0di0PW00r8qcx2?iv=1",
      "service_link": null
    },
    {
      "id": 52,
      "remark": null,
      "type": "商品",
      "product_id": "87623",
      "name": "自然标记白巧克力床垫",
      "value": "2899",
      "count": "2",
      "w_bg_pic": "https://img.haohaozhu.cn/Op-imageShow/7cbfd20di0di05i00r8qdc5?iv=1",
      "service_link": null
    },
    {
      "id": 53,
      "remark": null,
      "type": "商品",
      "product_id": "218979",
      "name": "冬熊轻奢科技绒布单床",
      "value": "5976",
      "count": "1",
      "w_bg_pic": "https://img.haohaozhu.cn/Op-imageShow/00ab620di0di0Sb00r8qdio?iv=1",
      "service_link": null
    },
    {
      "id": 54,
      "remark": null,
      "type": "商品",
      "product_id": "217793",
      "name": "老板嵌入式蒸烤箱",
      "value": "4999",
      "count": "1",
      "w_bg_pic": "https://img.haohaozhu.cn/Op-imageShow/d91c520di0di0Aq00r8qdqr?iv=1",
      "service_link": null
    },
    {
      "id": 55,
      "remark": null,
      "type": "商品",
      "product_id": "181939",
      "name": "三棵树云绘儿童漆",
      "value": "1299",
      "count": "4",
      "w_bg_pic": "https://img.haohaozhu.cn/Op-imageShow/e130c30di0di0ne00r8qc8t?iv=1",
      "service_link": null
    },
    {
      "id": 56,
      "remark": null,
      "type": "商品",
      "product_id": "209031",
      "name": "Dear-F组合挂画",
      "value": "238",
      "count": "25",
      "w_bg_pic": "https://img.haohaozhu.cn/Op-imageShow/0b1fa20di0di0Lg00r8rmz9?iv=1",
      "service_link": null
    },
    {
      "id": 57,
      "remark": null,
      "type": "商品",
      "product_id": "218851",
      "name": "芭蕉果动态护脊床垫",
      "value": "4299",
      "count": "2",
      "w_bg_pic": "https://img.haohaozhu.cn/Op-imageShow/1197020di0di0ZI00r8qdxh?iv=1",
      "service_link": null
    },
    {
      "id": 58,
      "remark": null,
      "type": "商品",
      "product_id": "72453",
      "name": "可米生活猫将军摆件",
      "value": "399",
      "count": "13",
      "w_bg_pic": "https://img.haohaozhu.cn/Op-imageShow/f756820m80m80xj00r8s435?iv=1",
      "service_link": null
    },
    {
      "id": 59,
      "remark": null,
      "type": "商品",
      "product_id": "220187",
      "name": "花王快丽莱除尘拖把",
      "value": "158",
      "count": "36",
      "w_bg_pic": "https://img.haohaozhu.cn/Op-imageShow/7483620di0di0WF00r8s8cd?iv=1",
      "service_link": null
    },
    {
      "id": 60,
      "remark": "KA 合作",
      "type": "商品",
      "product_id": "38937",
      "name": "OSIM傲胜8变小天后",
      "value": "9999",
      "count": "1",
      "w_bg_pic": "https://img.haohaozhu.cn/Op-imageShow/624a930di0di0VB00r8s8lh?iv=1",
      "service_link": null
    },
    {
      "id": 61,
      "remark": "KA 合作",
      "type": "商品",
      "product_id": "220180",
      "name": "世净冰箱除味杀菌器",
      "value": "199",
      "count": "26",
      "w_bg_pic": "https://img.haohaozhu.cn/Op-imageShow/578b720di0di0Kv00r8q5mb?iv=1",
      "service_link": null
    },
    {
      "id": 62,
      "remark": "KA 合作",
      "type": "商品",
      "product_id": "126913",
      "name": "小猴智能激光测距仪",
      "value": "199",
      "count": "26",
      "w_bg_pic": "https://img.haohaozhu.cn/Op-imageShow/d20f220di0di04d00r8s2sj?iv=1",
      "service_link": null
    },
    {
      "id": 63,
      "remark": "KA 合作",
      "type": "商品",
      "product_id": "220181",
      "name": "德禄智能升降桌",
      "value": "6288",
      "count": "1",
      "w_bg_pic": "https://img.haohaozhu.cn/Op-imageShow/ba98920di0di0iz00r8s2mj?iv=1",
      "service_link": null
    },
    {
      "id": 64,
      "remark": "KA 合作",
      "type": "商品",
      "product_id": "100941",
      "name": "凯迪仕可视猫眼智能锁",
      "value": "2399",
      "count": "3",
      "w_bg_pic": "https://img.haohaozhu.cn/Op-imageShow/77be420di0di0cW00r8s2gq?iv=1",
      "service_link": null
    },
    {
      "id": 65,
      "remark": "厚米周边",
      "type": "商品",
      "product_id": "196964",
      "name": "厚米玩偶",
      "value": "108",
      "count": "10",
      "w_bg_pic": "https://img.haohaozhu.cn/Op-imageShow/34ec820mq0mq0PL00r8rsfe?iv=1",
      "service_link": null
    },
    {
      "id": 66,
      "remark": "厚米周边",
      "type": "商品",
      "product_id": "196962",
      "name": "厚米地垫",
      "value": "68",
      "count": "10",
      "w_bg_pic": "https://img.haohaozhu.cn/Op-imageShow/ab851216i16i0RK00r8rsbo?iv=1",
      "service_link": null
    },
    {
      "id": 67,
      "remark": "厚米周边",
      "type": "商品",
      "product_id": "196965",
      "name": "厚米帆布袋",
      "value": "39",
      "count": "10",
      "w_bg_pic": "https://img.haohaozhu.cn/Op-imageShow/1aae9216i16i0ZM00r8rsi2?iv=1",
      "service_link": null
    },
    {
      "id": 68,
      "remark": "厚米周边",
      "type": "商品",
      "product_id": "196966",
      "name": "厚米围裙",
      "value": "58",
      "count": "10",
      "w_bg_pic": "https://img.haohaozhu.cn/Op-imageShow/518a121681680Ht00r8rs6g?iv=1",
      "service_link": null
    }
  ]
JSON;

//id、remark、type、product_id、name、value、count、w_bg_pic、service_link、pic

$products = json_decode($productJsonStr, true);

$insertData = [];

foreach ($products as $product) {
    $product_id = $product['product_id'] ?? 0;
    if ($product['type'] == '服务') {
        $product_id = 0;
    }
    $type = 0;
    if ($product['type'] == '服务') {
        $type = 2;
    } elseif ($product['type'] == '商品') {
        $type = 1;
    }

    $insertData[] = [
        'product_id' => $product_id,
        'product_name' => $product['name'],
        'product_type' => $type,
        'product_pic' => $product['w_bg_pic'],
        'product_value' => $product['value'],
        'total' => $product['count'],
        'num' => $product['count'],
        'is_show' => 1,
        'status' => 1,
        'create_time' => date('Y-m-d H:i:s', time()),
    ];
}

if (!empty($insertData)) {
    $ret = \Biz\model\springHomeDecActivity\ActivityProduct::dataMultiInsert($insertData);

    var_dump(\Biz\model\springHomeDecActivity\ActivityProduct::log());

    var_dump($ret);

}

exit;
